//
//  DCTransportViewController.m
//  JiuyaoMotorcade
//
//  Created by 大橙子 on 2018/11/28.
//  Copyright © 2018 Tomous. All rights reserved.
//

#import "DCTransportViewController.h"
#import "DCScrollView.h"
#import "DCCarManageViewController.h"
#import "DCDriverManagerViewController.h"
@interface DCTransportViewController ()<DCScrollViewDelegate>

@end

@implementation DCTransportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    DCScrollView *scrollView = [[DCScrollView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 230*HEIGHTSCALE6)];
    scrollView.delegate = self;
    scrollView.images = @[
                          IMAGENAME(@"AI_1"),
                          IMAGENAME(@"AI_2"),
                          IMAGENAME(@"AI_3"),
                          IMAGENAME(@"AI_4"),
                          IMAGENAME(@"AI_5")
                        ];
    scrollView.currentPageColor = BlueColor;
    scrollView.pageColor = [UIColor grayColor];
    [self.view addSubview:scrollView];
    
    CGFloat kMargin = 70*WIDTHSCALE6;
    CGFloat kWidth = (ScreenWidth - kMargin*3)/2;
    UIButton *carManagerBtn = [self setButtonWithFrame:CGRectMake(kMargin, scrollView.bottom + 60, kWidth, kWidth+35) image:IMAGENAME(@"车辆管理") title:@"车辆管理" target:self SEL:@selector(carmanagerBtnDidClick:)];
    carManagerBtn.tag = 0;
    [self.view addSubview:carManagerBtn];
    
    UIButton *driverManagerBtn = [self setButtonWithFrame:CGRectMake(carManagerBtn.right+kMargin, scrollView.bottom + 60, kWidth, kWidth+35) image:IMAGENAME(@"司机管理") title:@"司机管理" target:self SEL:@selector(carmanagerBtnDidClick:)];
    driverManagerBtn.tag = 1;
    [self.view addSubview:driverManagerBtn];
}

-(void)carmanagerBtnDidClick:(UIButton *)sender {
    
    if (sender.tag == 0) {
        DCCarManageViewController *carVC = [[DCCarManageViewController alloc]init];
        [self.navigationController pushViewController:carVC animated:YES];
    }else {
        DCDriverManagerViewController *driverVC = [[DCDriverManagerViewController alloc]init];
        [self.navigationController pushViewController:driverVC animated:YES];
    }
}
-(UIButton *)setButtonWithFrame:(CGRect)frame image:(UIImage *)image title:(NSString *)title target:(id)target SEL:(SEL)sel {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = frame;
    UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
    imageView.frame = CGRectMake(0, 0, button.width, button.width);
//    imageView.layer.cornerRadius = imageView.width/2;
//    imageView.clipsToBounds = YES;
    imageView.contentMode = UIViewContentModeRedraw;
    [button addSubview:imageView];
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, button.height-30, button.width, 30)];
    titleLabel.text = title;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.font = FONT(20);
    [button addSubview:titleLabel];
    [button addTarget:target action:sel forControlEvents:UIControlEventTouchUpInside];
    return button;
}
-(void)DC_scrollView:(DCScrollView *)scrollView indexOfClickedImageBtn:(NSUInteger)index {
    DCLog(@"点击了----%ld个",index);
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
